﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common.Background.Entity;


namespace Common.Background.Data
{
    public class WebManageUser_StrategyRepository : BackgroundRepositoryBase, IWebManageUser_StrategyRepository
    {

        //添加
        public void InsertStrategy(WebManageUser_Strategy entity)
        {
            base.InsertEntity(entity);
        }

        //修改
        public void UpdateStrategy(WebManageUser_Strategy entity)
        {
            var info = base.GetEntities<WebManageUser_Strategy>().FirstOrDefault(n => n.ID == entity.ID);
            base.DB.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, info);
            if (info != null)
            {
                info.BeginDate = entity.BeginDate;
                info.CreateDate = entity.CreateDate;
                info.ID = entity.ID;
                info.EndDate = entity.EndDate;
                info.IPArea = entity.IPArea;
                info.ManageUserID = entity.ManageUserID;
                info.Status = entity.Status;

                base.DB.SubmitChanges();
            }
        }

        //查询
        public IQueryable<WebManageUser_Strategy> GetModel()
        {
            return base.GetEntities<WebManageUser_Strategy>().Select(item => new WebManageUser_Strategy_Ext
            {
                BeginDate = item.BeginDate,
                CreateDate = item.CreateDate,
                ID = item.ID,
                EndDate = item.EndDate,
                IPArea = item.IPArea,
                ManageUserID = item.ManageUserID,
                Status = item.Status

            }).Cast<WebManageUser_Strategy>();
        }


        public WebManageUser_Strategy GetModel(int id)
        {
            return GetModel().FirstOrDefault(i => i.ManageUserID == id);
        }

        #region IRepository<WebManageUser_Strategy> 成员

        public void Update(WebManageUser_Strategy entity)
        {
            throw new NotImplementedException();
        }

        public void Update(IList<WebManageUser_Strategy> list)
        {
            throw new NotImplementedException();
        }

        public void Insert(WebManageUser_Strategy entity)
        {
            throw new NotImplementedException();
        }

        public void Insert(IList<WebManageUser_Strategy> list)
        {
            throw new NotImplementedException();
        }

        public WebManageUser_Strategy InsertGetIDENTITY(WebManageUser_Strategy entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(WebManageUser_Strategy entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(IList<WebManageUser_Strategy> list)
        {
            throw new NotImplementedException();
        }

        public WebManageUser_Strategy Find(params object[] keyValues)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
